# 字典推导式
nums = [1, 2, 3, 4, 5, 6]

num_dict = {num: num for num in nums}
print(num_dict)


# 从分数字典中只保留及格的学生
scores = {"Alice": 85, "Bob": 58, "Charlie": 71, "David": 49}

pass_stu = {key: val for key, val in scores.items() if val > 60}
print(pass_stu)

# 交换字典中的键和值
fruit_colors = {"apple": "red", "banana": "yellow", "grape": "purple"}

color_fruit_dict = {value: key for key, value in fruit_colors.items()}
print(color_fruit_dict)


# 将不及格成绩标记为"不及格"
scores = {"Alice": 85, "Bob": 58, "Charlie": 71, "David": 49}

new_scrore = {key: "不及格" if value < 60 else value for key, value in scores.items()}

print(new_scrore)

# 处理两个列表创建字典
keys = ["name", "age", "city"]
values = ["Alice", 25, "New York"]

person_stu = {keys[idx]: values[idx] for idx, item in enumerate(zip(keys, values))}
print(person_stu)
